package com.elec.controller.end;

import com.elec.domain.R;
import com.elec.domain.entity.User;
import com.elec.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author yu
 * @date 2024/7/5
 */
@RestController
@RequestMapping("end/user")
public class UserController {
    @Resource
    private UserService userService;
    @PostMapping
    public R add(@RequestBody User user){
        return userService.add(user);
    }
    @DeleteMapping("{id}")
    public R delete(@PathVariable("id") Long id){
        return userService.delete(id);
    }
    @PutMapping
    public R update(@RequestBody User user){
        return userService.update(user);
    }
    @GetMapping("{id}")
    public R get(@PathVariable("id") Long id){
        return userService.get(id);
    }
    @GetMapping("list")
    public R getList(@RequestParam(defaultValue = "1") Integer pageNum,
                     @RequestParam(defaultValue = "10") Integer pageSize,
                     User user){
        return userService.getList(pageNum, pageSize, user);
    }
}
